package com.kkb.robotcustomerservice.controller;


import com.kkb.robotcustomerservice.entities.JsonResult;
import org.springframework.web.bind.annotation.*;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("/login")
@CrossOrigin
public class LoginController {

    @PostMapping("/check")
    public JsonResult<Integer> login(@RequestParam("userName") String userName,
                                    @RequestParam("password") String password){
        JsonResult<Integer> result = new JsonResult<>();
        if ("admin".equals(userName) && "123".equals(password)){
            //data是0 表示用户
            result.setData(0);
            result.setMsg("请求成功");
            result.setCode(0);
            result.setSuccess(true);
        }else if (("root").equals(userName) && "123456".equals(password)){
            //data是1 表示管理员
            result.setData(1);
            result.setMsg("请求成功");
            result.setCode(0);
            result.setSuccess(true);
        }else {
            result.setData(3);
            result.setMsg("请求成功");
            result.setCode(0);
            result.setSuccess(true);
        }
        return result;
    }
}
